function customerDepartment(oriData, customerDepartment) {
    const splitStr = '-SpdeSo,fe-'

    const targetNameMap = new Map()
    for (const item of customerDepartment) {
        targetNameMap.set(item.name + splitStr + item.level, item)
    }

    const nameList = []
    for (const item of oriData) {
        const nameSplit = item.部门全称.split('\\')

        for (let i = 1; i < nameSplit.length; i++) {
            const setKey = nameSplit[i] + splitStr + (i + 1)
            const target = targetNameMap.get(setKey)
            if (target) {
                target.path = nameSplit.slice(0, i)
                targetNameMap.set(setKey, target)
                nameList.push(...target.path)
            }
        }
    }

    return {
        list: Array.from(targetNameMap.values()),
        nameList: Array.from(new Set(nameList))
    }
}

function setCustomerDepartment(data, parentData) {
    const splitStr = '-SpdeSo,fe-'

    const parentMap = new Map()
    for (const item of parentData) {
        parentMap.set(item.name + splitStr + item.level, item.id)
    }

    for (const item of data) {
        item.path = item.path.map((name, index) => parentMap.get(name + splitStr + (index + 1)))
        item.parentId = item.path[item.path.length - 1]
    }

    return data
}